<template>
	<view class="bf mh100">
		<view class="p3">
			<view class="mb30 t-c">核销码</view>
			<view class="f-c">
				<view class="zqmc f-c" :class="{'mr30':i<zqmArr.length-1}" v-for="(v,i) in zqmArr" :key='i'>{{v}}</view>
			</view>
		</view>
		<view class="foot-btnc">
			<button @click="qrhx" :disabled="loading" :loading="loading" class="foot-btn" :style="{background:tColor}">核销</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	import utils from '@/common/utils.js'
	export default {
		name: 'dp-hx',
		components: {},
		data() {
			return {
				loading: false,
				params: {
					selfCode: '',
					type: 'verification',
				},
				zqmArr: []
			}
		},
		onLoad(options) {
			this.params.selfCode = decodeURIComponent(options.code.replace(/\"/g, ""))
			this.zqmArr = decodeURIComponent(options.code.replace(/\"/g, "") || '1234567').split('')
			// console.log(this.zqmArr)
			this.util.setNT('核销')
		},
		computed: {},
		methods: {
			async qrhx() {
				try {
					await this.util.modal('确认核销?')
				} catch (e) {
					return
				}
				this.loading = true
				let res = await this.util.request({
					'url': this.api.ddcz,
					method: 'POST',
					mask: 1,
					data: this.params,
				}).catch((e) => {
					console.log("核销失败：",e)
					this.loading = false
				})
				if (res) {
					this.util.message('核销成功', 3)
					utils.swnb(1000)
				}
			},
		},
	}
</script>
<style scoped lang="scss">
	.zqmc {
		width: 80rpx;
		height: 80rpx;
		border-radius: 10rpx;
		border: 1px dashed #ddd;
	}
</style>
